Merged
Conversation
fasttime
commented
Nov 21, 2024
Comment on lines
-38
to
+42
| rules: { | ||
| rules: /** @type {const} */ ({ | ||
| "json/no-duplicate-keys": "error", | ||
| "json/no-empty-keys": "error", | ||
| "json/no-unsafe-values": "error", | ||
| }, | ||
| }), |
Member
Author
There was a problem hiding this comment.
This is const cast syntax. I'm using this to ensure that properties in the rules object have type "error" rather than string, because string is too wide to be assigned to a severity:
type StringSeverity = "off" | "warn" | "error";https://github.com/eslint/eslint/blob/v9.15.0/lib/types/index.d.ts#L917
| export default { | ||
| meta: { | ||
| type: "problem", | ||
| type: /** @type {const} */ ("problem"), |
Member
Author
There was a problem hiding this comment.
This ensures that the type property has type "problem" rather than string so it matches the definition in the interface:
type?: "problem" | "suggestion" | "layout" | undefined;https://github.com/eslint/eslint/blob/v9.15.0/lib/types/index.d.ts#L760
nzakas
approved these changes
Nov 21, 2024
Member
nzakas
left a comment
There was a problem hiding this comment.
LGTM. This is really cool. Thanks!
Merged
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites checklist
What is the purpose of this pull request?
Add type tests and fix some problems in the types.
What changes did you make? (Give an overview)
Added type tests to the CI workflow. I had to fix some minor issues in the typings of rules metadata and in the recommended config to match the signature of
ESLint.Plugin. This is why this pull request is taggedfix:.Related Issues
fixes #61
Is there anything you'd like reviewers to focus on?